module port2RamUpdateCrossBar (
    input wire clk,
    input wire rst,
    input wire [15:0] enqueue_update_en_port,
    input wire [5:0] enqueue_update_priority_port [0:15],
    input wire [7:0] is_first_tail_port [0:15],
    input wire [15:0] enqueue_tail_old_port [0:15],
    input wire [15:0] enqueue_tail_new_port [0:15],
    output reg [31:0] enqueue_update_en_ram,
    output reg [7:0] is_first_tail_ram [0:31],
    output reg [9:0] enqueue_tail_old_ram [0:31],
    output reg [15:0] enqueue_tail_new_ram [0:31]
);

    wire [31:0] enqueue_update_en_port1;
    wire [31:0] enqueue_update_en_port2;
    wire [31:0] enqueue_update_en_port3;
    wire [31:0] enqueue_update_en_port4;
    wire [31:0] enqueue_update_en_port5;
    wire [31:0] enqueue_update_en_port6;
    wire [31:0] enqueue_update_en_port7;
    wire [31:0] enqueue_update_en_port8;
    wire [31:0] enqueue_update_en_port9;
    wire [31:0] enqueue_update_en_port10;
    wire [31:0] enqueue_update_en_port11;
    wire [31:0] enqueue_update_en_port12;
    wire [31:0] enqueue_update_en_port13;
    wire [31:0] enqueue_update_en_port14;
    wire [31:0] enqueue_update_en_port15;
    wire [31:0] enqueue_update_en_port16;
    wire [5:0] enqueue_update_priority_port1 [0:31];
    wire [5:0] enqueue_update_priority_port2 [0:31];
    wire [5:0] enqueue_update_priority_port3 [0:31];
    wire [5:0] enqueue_update_priority_port4 [0:31];
    wire [5:0] enqueue_update_priority_port5 [0:31];
    wire [5:0] enqueue_update_priority_port6 [0:31];
    wire [5:0] enqueue_update_priority_port7 [0:31];
    wire [5:0] enqueue_update_priority_port8 [0:31];
    wire [5:0] enqueue_update_priority_port9 [0:31];
    wire [5:0] enqueue_update_priority_port10 [0:31];
    wire [5:0] enqueue_update_priority_port11 [0:31];
    wire [5:0] enqueue_update_priority_port12 [0:31];
    wire [5:0] enqueue_update_priority_port13 [0:31];
    wire [5:0] enqueue_update_priority_port14 [0:31];
    wire [5:0] enqueue_update_priority_port15 [0:31];
    wire [5:0] enqueue_update_priority_port16 [0:31];
    wire [7:0] is_first_tail_port1 [0:31];
    wire [7:0] is_first_tail_port2 [0:31];
    wire [7:0] is_first_tail_port3 [0:31];
    wire [7:0] is_first_tail_port4 [0:31];
    wire [7:0] is_first_tail_port5 [0:31];
    wire [7:0] is_first_tail_port6 [0:31];
    wire [7:0] is_first_tail_port7 [0:31];
    wire [7:0] is_first_tail_port8 [0:31];
    wire [7:0] is_first_tail_port9 [0:31];
    wire [7:0] is_first_tail_port10 [0:31];
    wire [7:0] is_first_tail_port11 [0:31];
    wire [7:0] is_first_tail_port12 [0:31];
    wire [7:0] is_first_tail_port13 [0:31];
    wire [7:0] is_first_tail_port14 [0:31];
    wire [7:0] is_first_tail_port15 [0:31];
    wire [7:0] is_first_tail_port16 [0:31];
    wire [9:0] enqueue_tail_old_port1 [0:31];
    wire [9:0] enqueue_tail_old_port2 [0:31];
    wire [9:0] enqueue_tail_old_port3 [0:31];
    wire [9:0] enqueue_tail_old_port4 [0:31];
    wire [9:0] enqueue_tail_old_port5 [0:31];
    wire [9:0] enqueue_tail_old_port6 [0:31];
    wire [9:0] enqueue_tail_old_port7 [0:31];
    wire [9:0] enqueue_tail_old_port8 [0:31];
    wire [9:0] enqueue_tail_old_port9 [0:31];
    wire [9:0] enqueue_tail_old_port10 [0:31];
    wire [9:0] enqueue_tail_old_port11 [0:31];
    wire [9:0] enqueue_tail_old_port12 [0:31];
    wire [9:0] enqueue_tail_old_port13 [0:31];
    wire [9:0] enqueue_tail_old_port14 [0:31];
    wire [9:0] enqueue_tail_old_port15 [0:31];
    wire [9:0] enqueue_tail_old_port16 [0:31];
    wire [15:0] enqueue_tail_new_port1 [0:31];
    wire [15:0] enqueue_tail_new_port2 [0:31];
    wire [15:0] enqueue_tail_new_port3 [0:31];
    wire [15:0] enqueue_tail_new_port4 [0:31];
    wire [15:0] enqueue_tail_new_port5 [0:31];
    wire [15:0] enqueue_tail_new_port6 [0:31];
    wire [15:0] enqueue_tail_new_port7 [0:31];
    wire [15:0] enqueue_tail_new_port8 [0:31];
    wire [15:0] enqueue_tail_new_port9 [0:31];
    wire [15:0] enqueue_tail_new_port10 [0:31];
    wire [15:0] enqueue_tail_new_port11 [0:31];
    wire [15:0] enqueue_tail_new_port12 [0:31];
    wire [15:0] enqueue_tail_new_port13 [0:31];
    wire [15:0] enqueue_tail_new_port14 [0:31];
    wire [15:0] enqueue_tail_new_port15 [0:31];
    wire [15:0] enqueue_tail_new_port16 [0:31];



    enqueueUpdateDeMuxer32 updateDeMux1(.clk(clk), .rst(rst), 
                                        .enqueue_update_en_in(enqueue_update_en_port[0]), .enqueue_update_priority_in(enqueue_update_priority_port[0]), .is_first_tail_in(is_first_tail_port[0]), .enqueue_tail_old_in(enqueue_tail_old_port[0]), .enqueue_tail_new_in(enqueue_tail_new_port[0]), 
                                        .enqueue_update_en_out(enqueue_update_en_port1), .enqueue_update_priority_out(enqueue_update_priority_port1), .is_first_tail_out(is_first_tail_port1), .enqueue_tail_old_out(enqueue_tail_old_port1), .enqueue_tail_new_out(enqueue_tail_new_port1));
    
    enqueueUpdateDeMuxer32 updateDeMux2(.clk(clk), .rst(rst), 
                                        .enqueue_update_en_in(enqueue_update_en_port[1]), .enqueue_update_priority_in(enqueue_update_priority_port[1]), .is_first_tail_in(is_first_tail_port[1]), .enqueue_tail_old_in(enqueue_tail_old_port[1]), .enqueue_tail_new_in(enqueue_tail_new_port[1]), 
                                        .enqueue_update_en_out(enqueue_update_en_port2), .enqueue_update_priority_out(enqueue_update_priority_port2), .is_first_tail_out(is_first_tail_port2), .enqueue_tail_old_out(enqueue_tail_old_port2), .enqueue_tail_new_out(enqueue_tail_new_port2));

    enqueueUpdateDeMuxer32 updateDeMux3(.clk(clk), .rst(rst), 
                                        .enqueue_update_en_in(enqueue_update_en_port[2]), .enqueue_update_priority_in(enqueue_update_priority_port[2]), .is_first_tail_in(is_first_tail_port[2]), .enqueue_tail_old_in(enqueue_tail_old_port[2]), .enqueue_tail_new_in(enqueue_tail_new_port[2]), 
                                        .enqueue_update_en_out(enqueue_update_en_port3), .enqueue_update_priority_out(enqueue_update_priority_port3), .is_first_tail_out(is_first_tail_port3), .enqueue_tail_old_out(enqueue_tail_old_port3), .enqueue_tail_new_out(enqueue_tail_new_port3));

    enqueueUpdateDeMuxer32 updateDeMux4(.clk(clk), .rst(rst), 
                                        .enqueue_update_en_in(enqueue_update_en_port[3]), .enqueue_update_priority_in(enqueue_update_priority_port[3]), .is_first_tail_in(is_first_tail_port[3]), .enqueue_tail_old_in(enqueue_tail_old_port[3]), .enqueue_tail_new_in(enqueue_tail_new_port[3]), 
                                        .enqueue_update_en_out(enqueue_update_en_port4), .enqueue_update_priority_out(enqueue_update_priority_port4), .is_first_tail_out(is_first_tail_port4), .enqueue_tail_old_out(enqueue_tail_old_port4), .enqueue_tail_new_out(enqueue_tail_new_port4));

    enqueueUpdateDeMuxer32 updateDeMux5(.clk(clk), .rst(rst), 
                                        .enqueue_update_en_in(enqueue_update_en_port[4]), .enqueue_update_priority_in(enqueue_update_priority_port[4]), .is_first_tail_in(is_first_tail_port[4]), .enqueue_tail_old_in(enqueue_tail_old_port[4]), .enqueue_tail_new_in(enqueue_tail_new_port[4]), 
                                        .enqueue_update_en_out(enqueue_update_en_port5), .enqueue_update_priority_out(enqueue_update_priority_port5), .is_first_tail_out(is_first_tail_port5), .enqueue_tail_old_out(enqueue_tail_old_port5), .enqueue_tail_new_out(enqueue_tail_new_port5));
    
    enqueueUpdateDeMuxer32 updateDeMux6(.clk(clk), .rst(rst), 
                                        .enqueue_update_en_in(enqueue_update_en_port[5]), .enqueue_update_priority_in(enqueue_update_priority_port[5]), .is_first_tail_in(is_first_tail_port[5]), .enqueue_tail_old_in(enqueue_tail_old_port[5]), .enqueue_tail_new_in(enqueue_tail_new_port[5]), 
                                        .enqueue_update_en_out(enqueue_update_en_port6), .enqueue_update_priority_out(enqueue_update_priority_port6), .is_first_tail_out(is_first_tail_port6), .enqueue_tail_old_out(enqueue_tail_old_port6), .enqueue_tail_new_out(enqueue_tail_new_port6));

    enqueueUpdateDeMuxer32 updateDeMux7(.clk(clk), .rst(rst), 
                                        .enqueue_update_en_in(enqueue_update_en_port[6]), .enqueue_update_priority_in(enqueue_update_priority_port[6]), .is_first_tail_in(is_first_tail_port[6]), .enqueue_tail_old_in(enqueue_tail_old_port[6]), .enqueue_tail_new_in(enqueue_tail_new_port[6]), 
                                        .enqueue_update_en_out(enqueue_update_en_port7), .enqueue_update_priority_out(enqueue_update_priority_port7), .is_first_tail_out(is_first_tail_port7), .enqueue_tail_old_out(enqueue_tail_old_port7), .enqueue_tail_new_out(enqueue_tail_new_port7));

    enqueueUpdateDeMuxer32 updateDeMux8(.clk(clk), .rst(rst), 
                                        .enqueue_update_en_in(enqueue_update_en_port[7]), .enqueue_update_priority_in(enqueue_update_priority_port[7]), .is_first_tail_in(is_first_tail_port[7]), .enqueue_tail_old_in(enqueue_tail_old_port[7]), .enqueue_tail_new_in(enqueue_tail_new_port[7]), 
                                        .enqueue_update_en_out(enqueue_update_en_port8), .enqueue_update_priority_out(enqueue_update_priority_port8), .is_first_tail_out(is_first_tail_port8), .enqueue_tail_old_out(enqueue_tail_old_port8), .enqueue_tail_new_out(enqueue_tail_new_port8));

    enqueueUpdateDeMuxer32 updateDeMux9(.clk(clk), .rst(rst), 
                                        .enqueue_update_en_in(enqueue_update_en_port[8]), .enqueue_update_priority_in(enqueue_update_priority_port[8]), .is_first_tail_in(is_first_tail_port[8]), .enqueue_tail_old_in(enqueue_tail_old_port[8]), .enqueue_tail_new_in(enqueue_tail_new_port[8]), 
                                        .enqueue_update_en_out(enqueue_update_en_port9), .enqueue_update_priority_out(enqueue_update_priority_port9), .is_first_tail_out(is_first_tail_port9), .enqueue_tail_old_out(enqueue_tail_old_port9), .enqueue_tail_new_out(enqueue_tail_new_port9));
    
    enqueueUpdateDeMuxer32 updateDeMux10(.clk(clk), .rst(rst), 
                                        .enqueue_update_en_in(enqueue_update_en_port[9]), .enqueue_update_priority_in(enqueue_update_priority_port[9]), .is_first_tail_in(is_first_tail_port[9]), .enqueue_tail_old_in(enqueue_tail_old_port[9]), .enqueue_tail_new_in(enqueue_tail_new_port[9]), 
                                        .enqueue_update_en_out(enqueue_update_en_port10), .enqueue_update_priority_out(enqueue_update_priority_port10), .is_first_tail_out(is_first_tail_port10), .enqueue_tail_old_out(enqueue_tail_old_port10), .enqueue_tail_new_out(enqueue_tail_new_port10));

    enqueueUpdateDeMuxer32 updateDeMux11(.clk(clk), .rst(rst), 
                                        .enqueue_update_en_in(enqueue_update_en_port[10]), .enqueue_update_priority_in(enqueue_update_priority_port[10]), .is_first_tail_in(is_first_tail_port[10]), .enqueue_tail_old_in(enqueue_tail_old_port[10]), .enqueue_tail_new_in(enqueue_tail_new_port[10]), 
                                        .enqueue_update_en_out(enqueue_update_en_port11), .enqueue_update_priority_out(enqueue_update_priority_port11), .is_first_tail_out(is_first_tail_port11), .enqueue_tail_old_out(enqueue_tail_old_port11), .enqueue_tail_new_out(enqueue_tail_new_port11));

    enqueueUpdateDeMuxer32 updateDeMux12(.clk(clk), .rst(rst), 
                                        .enqueue_update_en_in(enqueue_update_en_port[11]), .enqueue_update_priority_in(enqueue_update_priority_port[11]), .is_first_tail_in(is_first_tail_port[11]), .enqueue_tail_old_in(enqueue_tail_old_port[11]), .enqueue_tail_new_in(enqueue_tail_new_port[11]), 
                                        .enqueue_update_en_out(enqueue_update_en_port12), .enqueue_update_priority_out(enqueue_update_priority_port12), .is_first_tail_out(is_first_tail_port12), .enqueue_tail_old_out(enqueue_tail_old_port12), .enqueue_tail_new_out(enqueue_tail_new_port12));

    enqueueUpdateDeMuxer32 updateDeMux13(.clk(clk), .rst(rst), 
                                        .enqueue_update_en_in(enqueue_update_en_port[12]), .enqueue_update_priority_in(enqueue_update_priority_port[12]), .is_first_tail_in(is_first_tail_port[12]), .enqueue_tail_old_in(enqueue_tail_old_port[12]), .enqueue_tail_new_in(enqueue_tail_new_port[12]), 
                                        .enqueue_update_en_out(enqueue_update_en_port13), .enqueue_update_priority_out(enqueue_update_priority_port13), .is_first_tail_out(is_first_tail_port13), .enqueue_tail_old_out(enqueue_tail_old_port13), .enqueue_tail_new_out(enqueue_tail_new_port13));
    
    enqueueUpdateDeMuxer32 updateDeMux14(.clk(clk), .rst(rst), 
                                        .enqueue_update_en_in(enqueue_update_en_port[13]), .enqueue_update_priority_in(enqueue_update_priority_port[13]), .is_first_tail_in(is_first_tail_port[13]), .enqueue_tail_old_in(enqueue_tail_old_port[13]), .enqueue_tail_new_in(enqueue_tail_new_port[13]), 
                                        .enqueue_update_en_out(enqueue_update_en_port14), .enqueue_update_priority_out(enqueue_update_priority_port14), .is_first_tail_out(is_first_tail_port14), .enqueue_tail_old_out(enqueue_tail_old_port14), .enqueue_tail_new_out(enqueue_tail_new_port14));

    enqueueUpdateDeMuxer32 updateDeMux15(.clk(clk), .rst(rst), 
                                        .enqueue_update_en_in(enqueue_update_en_port[14]), .enqueue_update_priority_in(enqueue_update_priority_port[14]), .is_first_tail_in(is_first_tail_port[14]), .enqueue_tail_old_in(enqueue_tail_old_port[14]), .enqueue_tail_new_in(enqueue_tail_new_port[14]), 
                                        .enqueue_update_en_out(enqueue_update_en_port15), .enqueue_update_priority_out(enqueue_update_priority_port15), .is_first_tail_out(is_first_tail_port15), .enqueue_tail_old_out(enqueue_tail_old_port15), .enqueue_tail_new_out(enqueue_tail_new_port15));

    enqueueUpdateDeMuxer32 updateDeMux16(.clk(clk), .rst(rst), 
                                        .enqueue_update_en_in(enqueue_update_en_port[15]), .enqueue_update_priority_in(enqueue_update_priority_port[15]), .is_first_tail_in(is_first_tail_port[15]), .enqueue_tail_old_in(enqueue_tail_old_port[15]), .enqueue_tail_new_in(enqueue_tail_new_port[15]), 
                                        .enqueue_update_en_out(enqueue_update_en_port16), .enqueue_update_priority_out(enqueue_update_priority_port16), .is_first_tail_out(is_first_tail_port16), .enqueue_tail_old_out(enqueue_tail_old_port16), .enqueue_tail_new_out(enqueue_tail_new_port16));
    
    genvar euIndex;
    generate
        for (euIndex=0; euIndex<32; euIndex=euIndex+1) begin : enqueueUpdateMuxer
            enqueueUpdateMuxer16 updateMuxer(.clk(clk), .rst(rst), 
                                            .enqueue_update_en_1(enqueue_update_en_port1[euIndex]), .enqueue_update_en_2(enqueue_update_en_port2[euIndex]), .enqueue_update_en_3(enqueue_update_en_port3[euIndex]), .enqueue_update_en_4(enqueue_update_en_port4[euIndex]), .enqueue_update_en_5(enqueue_update_en_port5[euIndex]), .enqueue_update_en_6(enqueue_update_en_port6[euIndex]), .enqueue_update_en_7(enqueue_update_en_port7[euIndex]), .enqueue_update_en_8(enqueue_update_en_port8[euIndex]), .enqueue_update_en_9(enqueue_update_en_port9[euIndex]), .enqueue_update_en_10(enqueue_update_en_port10[euIndex]), .enqueue_update_en_11(enqueue_update_en_port11[euIndex]), .enqueue_update_en_12(enqueue_update_en_port12[euIndex]), .enqueue_update_en_13(enqueue_update_en_port13[euIndex]), .enqueue_update_en_14(enqueue_update_en_port14[euIndex]), .enqueue_update_en_15(enqueue_update_en_port15[euIndex]), .enqueue_update_en_16(enqueue_update_en_port16[euIndex]), 
                                            .enqueue_update_priority_1(enqueue_update_priority_port1[euIndex]), .enqueue_update_priority_2(enqueue_update_priority_port2[euIndex]), .enqueue_update_priority_3(enqueue_update_priority_port3[euIndex]), .enqueue_update_priority_4(enqueue_update_priority_port4[euIndex]), .enqueue_update_priority_5(enqueue_update_priority_port5[euIndex]), .enqueue_update_priority_6(enqueue_update_priority_port6[euIndex]), .enqueue_update_priority_7(enqueue_update_priority_port7[euIndex]), .enqueue_update_priority_8(enqueue_update_priority_port8[euIndex]), .enqueue_update_priority_9(enqueue_update_priority_port9[euIndex]), .enqueue_update_priority_10(enqueue_update_priority_port10[euIndex]), .enqueue_update_priority_11(enqueue_update_priority_port11[euIndex]), .enqueue_update_priority_12(enqueue_update_priority_port12[euIndex]), .enqueue_update_priority_13(enqueue_update_priority_port13[euIndex]), .enqueue_update_priority_14(enqueue_update_priority_port14[euIndex]), .enqueue_update_priority_15(enqueue_update_priority_port15[euIndex]), .enqueue_update_priority_16(enqueue_update_priority_port16[euIndex]), 
                                            .is_first_tail_1(is_first_tail_port1[euIndex]), .is_first_tail_2(is_first_tail_port2[euIndex]), .is_first_tail_3(is_first_tail_port3[euIndex]), .is_first_tail_4(is_first_tail_port4[euIndex]), .is_first_tail_5(is_first_tail_port5[euIndex]), .is_first_tail_6(is_first_tail_port6[euIndex]), .is_first_tail_7(is_first_tail_port7[euIndex]), .is_first_tail_8(is_first_tail_port8[euIndex]), .is_first_tail_9(is_first_tail_port9[euIndex]), .is_first_tail_10(is_first_tail_port10[euIndex]), .is_first_tail_11(is_first_tail_port11[euIndex]), .is_first_tail_12(is_first_tail_port12[euIndex]), .is_first_tail_13(is_first_tail_port13[euIndex]), .is_first_tail_14(is_first_tail_port14[euIndex]), .is_first_tail_15(is_first_tail_port15[euIndex]), .is_first_tail_16(is_first_tail_port16[euIndex]), 
                                            .enqueue_tail_old_1(enqueue_tail_old_port1[euIndex]), .enqueue_tail_old_2(enqueue_tail_old_port2[euIndex]), .enqueue_tail_old_3(enqueue_tail_old_port3[euIndex]), .enqueue_tail_old_4(enqueue_tail_old_port4[euIndex]), .enqueue_tail_old_5(enqueue_tail_old_port5[euIndex]), .enqueue_tail_old_6(enqueue_tail_old_port6[euIndex]), .enqueue_tail_old_7(enqueue_tail_old_port7[euIndex]), .enqueue_tail_old_8(enqueue_tail_old_port8[euIndex]), .enqueue_tail_old_9(enqueue_tail_old_port9[euIndex]), .enqueue_tail_old_10(enqueue_tail_old_port10[euIndex]), .enqueue_tail_old_11(enqueue_tail_old_port11[euIndex]), .enqueue_tail_old_12(enqueue_tail_old_port12[euIndex]), .enqueue_tail_old_13(enqueue_tail_old_port13[euIndex]), .enqueue_tail_old_14(enqueue_tail_old_port14[euIndex]), .enqueue_tail_old_15(enqueue_tail_old_port15[euIndex]), .enqueue_tail_old_16(enqueue_tail_old_port16[euIndex]), 
                                            .enqueue_tail_new_1(enqueue_tail_new_port1[euIndex]), .enqueue_tail_new_2(enqueue_tail_new_port2[euIndex]), .enqueue_tail_new_3(enqueue_tail_new_port3[euIndex]), .enqueue_tail_new_4(enqueue_tail_new_port4[euIndex]), .enqueue_tail_new_5(enqueue_tail_new_port5[euIndex]), .enqueue_tail_new_6(enqueue_tail_new_port6[euIndex]), .enqueue_tail_new_7(enqueue_tail_new_port7[euIndex]), .enqueue_tail_new_8(enqueue_tail_new_port8[euIndex]), .enqueue_tail_new_9(enqueue_tail_new_port9[euIndex]), .enqueue_tail_new_10(enqueue_tail_new_port10[euIndex]), .enqueue_tail_new_11(enqueue_tail_new_port11[euIndex]), .enqueue_tail_new_12(enqueue_tail_new_port12[euIndex]), .enqueue_tail_new_13(enqueue_tail_new_port13[euIndex]), .enqueue_tail_new_14(enqueue_tail_new_port14[euIndex]), .enqueue_tail_new_15(enqueue_tail_new_port15[euIndex]), .enqueue_tail_new_16(enqueue_tail_new_port16[euIndex]), 
                                            .enqueue_update_en(enqueue_update_en_ram[euIndex]), .is_first_tail(is_first_tail_ram[euIndex]), .enqueue_tail_old(enqueue_tail_old_ram[euIndex]), .enqueue_tail_new(enqueue_tail_new_ram[euIndex]));
        end
    endgenerate
    
endmodule